/*    */ package com.zimbra.cs.account;
/*    */ 
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GuestAccount
/*    */   extends Account
/*    */ {
/*    */   private final String digest;
/*    */   private String accessKey;
/*    */   public static final String EMAIL_ADDRESS_PUBLIC = "public";
/* 33 */   public static final Account ANONYMOUS_ACCT = new GuestAccount("public", null);
/*    */   
/*    */   public static final String GUID_PUBLIC = "99999999-9999-9999-9999-999999999999";
/*    */   
/*    */   public static final String GUID_AUTHUSER = "00000000-0000-0000-0000-000000000000";
/*    */   
/*    */ 
/*    */   private static Map<String, Object> getAnonAttrs()
/*    */   {
/* 42 */     Map<String, Object> attrs = new HashMap();
/* 43 */     attrs.put("uid", "public");
/* 44 */     attrs.put("zimbraId", "99999999-9999-9999-9999-999999999999");
/* 45 */     return attrs;
/*    */   }
/*    */   
/*    */   public GuestAccount(String emailAddress, String password) {
/* 49 */     super(emailAddress, "99999999-9999-9999-9999-999999999999", getAnonAttrs(), null, null);
/* 50 */     this.digest = AuthToken.generateDigest(emailAddress, password);
/*    */   }
/*    */   
/*    */   public GuestAccount(AuthToken auth)
/*    */   {
/* 55 */     super(auth.getExternalUserEmail() == null ? "" : auth.getExternalUserEmail(), "99999999-9999-9999-9999-999999999999", getAnonAttrs(), null, null);
/* 56 */     this.digest = auth.getDigest();
/* 57 */     this.accessKey = auth.getAccessKey();
/*    */   }
/*    */   
/*    */   public boolean matches(String emailAddress, String password) {
/* 61 */     if (getName().compareToIgnoreCase(emailAddress) != 0)
/* 62 */       return false;
/* 63 */     String matchDigest = AuthToken.generateDigest(getName(), password);
/*    */     
/* 65 */     return this.digest.compareTo(matchDigest) == 0;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean matchesAccessKey(String emailAddress, String accesskey)
/*    */   {
/* 73 */     if (this.accessKey == null)
/* 74 */       return false;
/* 75 */     return this.accessKey.compareTo(accesskey) == 0;
/*    */   }
/*    */   
/*    */   public String getDigest() {
/* 79 */     return this.digest;
/*    */   }
/*    */   
/*    */   public String getAccessKey() {
/* 83 */     return this.accessKey;
/*    */   }
/*    */   
/*    */   public boolean isIsExternalVirtualAccount()
/*    */   {
/* 88 */     return (!"public".equals(getName())) && (getAccessKey() == null);
/*    */   }
/*    */   
/*    */   public String getExternalUserMailAddress()
/*    */   {
/* 93 */     return isIsExternalVirtualAccount() ? getName() : null;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/GuestAccount.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */